package com.zty.xiaomi.server.Controller;

import com.zty.xiaomi.server.Dto.GetServiceInfoDto;
import com.zty.xiaomi.server.Entity.Service.Service;
import com.zty.xiaomi.server.Service.Service.ServiceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.io.IOException;
import java.util.List;

@CrossOrigin
@RestController
@RequestMapping("service")
public class ServiceController {
    @Autowired
    private ServiceService serviceService;

    @GetMapping("getAllService")
    private GetServiceInfoDto getAllService() throws IOException {
        GetServiceInfoDto getServiceInfoDto = new GetServiceInfoDto();
        List<Service> list = serviceService.getAllService();
        if (list.size() == 0) {
            getServiceInfoDto.setStatus("400");
            getServiceInfoDto.setMsg("暂无售后服务！");
        } else {
            getServiceInfoDto.setList(list);
            getServiceInfoDto.setStatus("200");
        }
        return getServiceInfoDto;
    }
}
